<template>
	<div id='XQTJchart' style="width: 480px;height:320px;margin:0 auto;"></div>
</template>

<script>
import * as echarts from 'echarts'
import {GETSEVENDAYSCOUNT} from '@/../static/js/apis.js'

export default{
	name: "XQTJchart",
	methods: {
		//绘制图形
		drawChart (datax,datay) {
			let myChart = echarts.init(document.getElementById('XQTJchart'))
			let options = {
			    title: {
			        text: '当前帐号活跃度',
			        left: 'left'
			    },
			    tooltip: {
			        trigger: 'item'
			    },
			     xAxis: {
			        type: 'category',
			        data: datax
			    },
			    yAxis: {
			        type: 'value'
			    },
			    color:['#5470c6'],
			    series: [{
			        data: datay,
			        type: 'bar',
			        barWidth : 30
			    }]
			};
			myChart.setOption(options, true)
		},
		getData () {
			const self = this;
			let datax=[];
			let datay=[];
			GETSEVENDAYSCOUNT('',function(res){
				if(res.data){
					//绘制图形
					 res.data.forEach(function(item, index) {
			                  datax.push(item.logTime)
			                  datay.push(item.total)
			           })
					self.drawChart(datax,datay);
				}
			})
		}
	},
	mounted () {
		this.getData();
	}
}
	
</script>

<style scoped>
	
</style>